﻿using System;
using System.Collections.Generic;
using System.Text;
using SharpDiary.Core.Data;
using SharpDiary.Core.Utility;

namespace SharpDiary.Core.ORMapping
{
    /// <summary>
    /// 命令组信息。
    /// </summary>
    public class ActionGroupInfo : DbMappingObjectBase
    {
        #region Fields & Properties

        private string _id = string.Empty;

        /// <summary>
        /// 获取或设置命令组编号。
        /// </summary>
        [FieldMapping(true, System.Data.DbType.String, false, true)]
        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }

        private string _name = string.Empty;

        /// <summary>
        /// 获取或设置名称。
        /// </summary>
        [FieldMapping(false, System.Data.DbType.String, false, false)]
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        private string _description = string.Empty;

        /// <summary>
        /// 获取或设置描述信息。
        /// </summary>
        [FieldMapping(false, System.Data.DbType.String, false, false)]
        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        private Int64 _validStatus = 0;

        /// <summary>
        /// 是否可用。(0: 不可用 1:可用)
        /// </summary>
        [FieldMapping(false, System.Data.DbType.Int64, false, false)]
        public Int64 ValidStatus
        {
            get { return _validStatus; }
            set { _validStatus = value; }
        }

        #endregion

        #region Constructors

        public ActionGroupInfo() { }

        #endregion

        #region Methods

        /// <summary>
        /// 获取所有命令组信息。
        /// </summary>
        /// <returns></returns>
        public static List<ActionGroupInfo> GetAllActionGroupsInfo()
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("select * from ActionGroupInfo where ValidStatus = 1");
            sql.AppendLine("order by SortId desc");

            return DbObjectMappingHelper.QueryObjectList<ActionGroupInfo>(sql.ToString());
        }

        #endregion
    }
}
